<template>
  <view class="my-wrapper">
    <view class="avatar-box mb10">
      <image class="avatar" :src="user.avatar" ></image>
      <text class="name">{{user.nickname}}</text>
    </view>
    <view class="line border-b" @click="goUrl('/packapp/plat/pages/my/myinfo')">
      <view class="item" >
        <view class="left">
          <text class="icon-user iconfont"></text>
          <text>账户管理</text>
        </view>
        <view class="right">
          <text class="icon-jiantou iconfont"></text>
        </view>
      </view>
    </view>
    <view class="line border-b" @click="goUrl('/wap.php?g=Wap&c=My&a=my_money')">
      <view class="item">
        <view class="left">
          <text class="icon-yue iconfont"></text>
          <text>我的余额</text>
        </view>
        <view class="right">
          <text>{{currency + user.now_money}}</text>
          <text class="icon-jiantou iconfont"></text>
        </view>
      </view>
    </view>
    <view class="line mb10" @click="goUrl('/packapp/plat/pages/my/my_order?state=0')">
      <view class="item">
        <view class="left">
          <text class="icon-dingdan2 iconfont"></text>
          <text>我的订单</text>
        </view>
        <view class="right">
          <text class="icon-jiantou iconfont"></text>
        </view>
      </view>
    </view>

    <view class="line border-b" @click="goUrl('/wap.php?c=My&a=about&from=paotui')">
      <view class="item">
        <view class="left">
          <text class="icon-shuoming iconfont"></text>
          <text>使用说明</text>
        </view>
        <view class="right">
          <text class="icon-jiantou iconfont"></text>
        </view>
      </view>
    </view>
    <view class="line mb10" @click="showList(true)">
      <view class="item">
        <view class="left">
          <text class="icon-kefu1 iconfont"></text>
          <text>联系客服</text>
        </view>
        <view class="right">
          <text class="icon-jiantou iconfont"></text>
        </view>
      </view>
    </view>

    <view v-if="moreLink.length > 0">
      <view class="line border-b" @click="goUrl('/wap.php?g=Wap&c=Groupnew&a=index')">
        <view class="item">
          <view class="left">
            <i class="icon iconfont">&#xe6a5;</i>
            <text>更多功能</text>
          </view>
          <view class="right">
            <text class="color9">本地团购外卖</text>
            <text class="icon-jiantou iconfont"></text>
          </view>
        </view>
      </view>
      <view class="line border-b" @click="goUrl('/wap.php?g=Wap&c=Mall&a=home')">
        <view class="item">
          <view class="left">
            <i class="icon iconfont">&#xe64d;</i>
            <text>本地商城</text>
          </view>
          <view class="right">
            <text class="color9">精选本地好货</text>
            <text class="icon-jiantou iconfont"></text>
          </view>
        </view>
      </view>
      <view class="line">
        <view class="item">
          <view class="left">
            <i class="icon iconfont">&#xe63c;</i>
            <text>小猪社群</text>
          </view>
          <view class="right">
            <text class="color9">寻找本地交流群</text>
            <text class="icon-jiantou iconfont"></text>
          </view>
        </view>
      </view>
    </view>
	
	<call :show="showcallMask" :list="phoneList" :linkUrl="linkUrl" @showHandler="showList"></call>
  </view>
</template>

<script>
import call from '../../appComponent/platcommon/call.vue'
import common from '../../utils/common.js'
var app = getApp()
var _this
export default {
  name: 'Myself',
  components: {call},
  data () {
    return {
      user: {},
      ticket: '',
      showTel: false,
      moreLink: [],
	  phoneList: [],
	  linkUrl: '',
	  showcallMask: false,
	  currency: '¥'
    }
  },
  onLoad () {
	_this = this
    this.user = app.globalData.userInfo
    this.ticket = uni.getStorageSync('ticket')
	common.getConfig((data) => {
		console.log('111111111', data)
		if (data.config.moreLink) {
			_this.moreLink = data.config.moreLink
		}
		if (data.config.site_phone) {
			var site_phone_arr = data.config.site_phone.split(' ');
			for(var i in site_phone_arr){
				_this.phoneList.push(site_phone_arr[i])
			}
		}
	})
    console.log('3333333333', this.user)
  },
  methods: {
    goUrl (url) {
		url = common.requestDomain + url + '&ticket=' + this.ticket + '&device_id=packapp'
		common.parseUrl(url);
    },
    showList (show) {
		console.log('是否显示电话弹窗', show)
		this.showcallMask = show
    }
  }
}
</script>

<style lang="stylus" scoped>
.my-wrapper
    color #000
	.avatar-box
		background #fff
		padding 20px
		font-size 18px
		.avatar
			width 52px
			height 52px
			border-radius 50%
			display inline-block
			vertical-align middle
			margin-right 15px
	.line
		background #fff
		line-height 40px
		font-size 14px
		.item
			margin-left 10px
			padding-right 10px
			display flex
			justify-content space-between
			align-items center
			.left
				.iconfont
					margin-right 10px
			.right
				font-size 12px
				display flex
				align-items center
				.iconfont
					color #999
	.border-b
	  border-bottom 1PX solid #f2f2f2
</style>
